home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 292_04 / tz80.asm < prev    next >
Assembly Source File  |  1990-07-16  |  27KB  |  1,014 lines

  1.     .title    Test of Z80 / HD64180 assembler
  2.  
  3.     offset    =    0x55        ;arbitrary constants
  4.     n    =    0x20
  5.     nn    =    0x0584
  6.  
  7.     ; notes:
  8.     ;    Leading 'a' operand is optional.
  9.     ;    If offset is ommitted 0 is assumed.
  10.  
  11.     ;***********************************************************
  12.     ;add with carry to 'a'
  13.     adc    a,(hl)            ; 8E
  14.     adc    a,offset(ix)        ; DD 8E 55
  15.     adc    a,offset(iy)        ; FD 8E 55
  16.     adc    a,a            ; 8F
  17.     adc    a,b            ; 88
  18.     adc    a,c            ; 89
  19.     adc    a,d            ; 8A
  20.     adc    a,e            ; 8B
  21.     adc    a,h            ; 8C
  22.     adc    a,l            ; 8D
  23.     adc    a,#n            ; CE 20
  24.     ;***********************************************************
  25.     adc    (hl)            ; 8E
  26.     adc    offset(ix)        ; DD 8E 55
  27.     adc    offset(iy)        ; FD 8E 55
  28.     adc    a            ; 8F
  29.     adc    b            ; 88
  30.     adc    c            ; 89
  31.     adc    d            ; 8A
  32.     adc    e            ; 8B
  33.     adc    h            ; 8C
  34.     adc    l            ; 8D
  35.     adc    #n            ; CE 20
  36.     ;***********************************************************
  37.     ;add with carry register pair to 'hl'
  38.     adc    hl,bc            ; ED 4A
  39.     adc    hl,de            ; ED 5A
  40.     adc    hl,hl            ; ED 6A
  41.     adc    hl,sp            ; ED 7A
  42.     ;***********************************************************
  43.     ;add operand to 'a'
  44.     add    a,(hl)            ; 86
  45.     add    a,offset(ix)        ; DD 86 55
  46.     add    a,offset(iy)        ; FD 86 55
  47.     add    a,a            ; 87
  48.     add    a,b            ; 80
  49.     add    a,c            ; 81
  50.     add    a,d            ; 82
  51.     add    a,e            ; 83
  52.     add    a,h            ; 84
  53.     add    a,l            ; 85
  54.     add    a,#n            ; C6 20
  55.     ;***********************************************************
  56.     ;add register pair to 'hl'
  57.     add    hl,bc            ; 09
  58.     add    hl,de            ; 19
  59.     add    hl,hl            ; 29
  60.     add    hl,sp            ; 39
  61.     ;***********************************************************
  62.     ;add register pair to 'ix'
  63.     add    ix,bc            ; DD 09
  64.     add    ix,de            ; DD 19
  65.     add    ix,ix            ; DD 29
  66.     add    ix,sp            ; DD 39
  67.     ;***********************************************************
  68.     ;add register pair to 'iy'
  69.     add    iy,bc            ; FD 09
  70.     add    iy,de            ; FD 19
  71.     add    iy,iy            ; FD 29
  72.     add    iy,sp            ; FD 39
  73.     ;***********************************************************
  74.     ;logical 'and' operand with 'a'
  75.     and    a,(hl)            ; A6
  76.     and    a,offset(ix)        ; DD A6 55
  77.     and    a,offset(iy)        ; FD A6 55
  78.     and    a,a            ; A7
  79.     and    a,b            ; A0
  80.     and    a,c            ; A1
  81.     and    a,d            ; A2
  82.     and    a,e            ; A3
  83.     and    a,h            ; A4
  84.     and    a,l            ; A5
  85.     and    a,#n            ; E6 20
  86.     ;***********************************************************
  87.     ;test bit of location or register
  88.     bit    0,(hl)            ; CB 46
  89.     bit    0,offset(ix)        ; DD CB 55 46
  90.     bit    0,offset(iy)        ; FD CB 55 46
  91.     bit    0,a            ; CB 47
  92.     bit    0,b            ; CB 40
  93.     bit    0,c            ; CB 41
  94.     bit    0,d            ; CB 42
  95.     bit    0,e            ; CB 43
  96.     bit    0,h            ; CB 44
  97.     bit    0,l            ; CB 45
  98.     bit    1,(hl)            ; CB 4E
  99.     bit    1,offset(ix)        ; DD CB 55 4E
  100.     bit    1,offset(iy)        ; FD CB 55 4E
  101.     bit    1,a            ; CB 4F
  102.     bit    1,b            ; CB 48
  103.     bit    1,c            ; CB 49
  104.     bit    1,d            ; CB 4A
  105.     bit    1,e            ; CB 4B
  106.     bit    1,h            ; CB 4C
  107.     bit    1,l            ; CB 4D
  108.     bit    2,(hl)            ; CB 56
  109.     bit    2,offset(ix)        ; DD CB 55 56
  110.     bit    2,offset(iy)        ; FD CB 55 56
  111.     bit    2,a            ; CB 57
  112.     bit    2,b            ; CB 50
  113.     bit    2,c            ; CB 51
  114.     bit    2,d            ; CB 52
  115.     bit    2,e            ; CB 53
  116.     bit    2,h            ; CB 54
  117.     bit    2,l            ; CB 55
  118.     bit    3,(hl)            ; CB 5E
  119.     bit    3,offset(ix)        ; DD CB 55 5E
  120.     bit    3,offset(iy)        ; FD CB 55 5E
  121.     bit    3,a            ; CB 5F
  122.     bit    3,b            ; CB 58
  123.     bit    3,c            ; CB 59
  124.     bit    3,d            ; CB 5A
  125.     bit    3,e            ; CB 5B
  126.     bit    3,h            ; CB 5C
  127.     bit    3,l            ; CB 5D
  128.     bit    4,(hl)            ; CB 66
  129.     bit    4,offset(ix)        ; DD CB 55 66
  130.     bit    4,offset(iy)        ; FD CB 55 66
  131.     bit    4,a            ; CB 67
  132.     bit    4,b            ; CB 60
  133.     bit    4,c            ; CB 61
  134.     bit    4,d            ; CB 62
  135.     bit    4,e            ; CB 63
  136.     bit    4,h            ; CB 64
  137.     bit    4,l            ; CB 65
  138.     bit    5,(hl)            ; CB 6E
  139.     bit    5,offset(ix)        ; DD CB 55 6E
  140.     bit    5,offset(iy)        ; FD CB 55 6E
  141.     bit    5,a            ; CB 6F
  142.     bit    5,b            ; CB 68
  143.     bit    5,c            ; CB 69
  144.     bit    5,d            ; CB 6A
  145.     bit    5,e            ; CB 6B
  146.     bit    5,h            ; CB 6C
  147.     bit    5,l            ; CB 6D
  148.     bit    6,(hl)            ; CB 76
  149.     bit    6,offset(ix)        ; DD CB 55 76
  150.     bit    6,offset(iy)        ; FD CB 55 76
  151.     bit    6,a            ; CB 77
  152.     bit    6,b            ; CB 70
  153.     bit    6,c            ; CB 71
  154.     bit    6,d            ; CB 72
  155.     bit    6,e            ; CB 73
  156.     bit    6,h            ; CB 74
  157.     bit    6,l            ; CB 75
  158.     bit    7,(hl)            ; CB 7E
  159.     bit    7,offset(ix)        ; DD CB 55 7E
  160.     bit    7,offset(iy)        ; FD CB 55 7E
  161.     bit    7,a            ; CB 7F
  162.     bit    7,b            ; CB 78
  163.     bit    7,c            ; CB 79
  164.     bit    7,d            ; CB 7A
  165.     bit    7,e            ; CB 7B
  166.     bit    7,h            ; CB 7C
  167.     bit    7,l            ; CB 7D
  168.     ;***********************************************************
  169.     ;call subroutine at nn if condition is true
  170.     call    C,nn            ; DC 84 05
  171.     call    M,nn            ; FC 84 05
  172.     call    NC,nn            ; D4 84 05
  173.     call    NZ,nn            ; C4 84 05
  174.     call    P,nn            ; F4 84 05
  175.     call    PE,nn            ; EC 84 05
  176.     call    PO,nn            ; E4 84 05
  177.     call    Z,nn            ; CC 84 05
  178.     ;***********************************************************
  179.     ;unconditional call to subroutine at nn
  180.     call    nn            ; CD 84 05
  181.     ;***********************************************************
  182.     ;complement carry flag
  183.     ccf                ; 3F
  184.     ;***********************************************************
  185.     ;compare operand with 'a'
  186.     cp    a,(hl)            ; BE
  187.     cp    a,offset(ix)        ; DD BE 55
  188.     cp    a,offset(iy)        ; FD BE 55
  189.     cp    a,a            ; BF
  190.     cp    a,b            ; B8
  191.     cp    a,c            ; B9
  192.     cp    a,d            ; BA
  193.     cp    a,e            ; BB
  194.     cp    a,h            ; BC
  195.     cp    a,l            ; BD
  196.     cp    a,#n            ; FE 20
  197.     ;***********************************************************
  198.     ;compare location (hl) and 'a'
  199.     ;decrement 'hl' and 'bc'
  200.     cpd                ; ED A9
  201.     ;***********************************************************
  202.     ;compare location (hl) and 'a'
  203.     ;decrement 'hl' and 'bc'
  204.     ;repeat until 'bc' = 0
  205.     cpdr                ; ED B9
  206.     ;***********************************************************
  207.     ;compare location (hl) and 'a'
  208.     ;increment 'hl' and decrement 'bc'
  209.     cpi                ; ED A1
  210.     ;***********************************************************
  211.     ;compare location (hl) and 'a'
  212.     ;increment 'hl' and decrement 'bc'
  213.     ;repeat until 'bc' = 0
  214.     cpir                ; ED B1
  215.     ;***********************************************************
  216.     ;1's complement of 'a'
  217.     cpl                ; 2F
  218.     ;***********************************************************
  219.     ;decimal adjust 'a'
  220.     daa                ; 27
  221.     ;***********************************************************
  222.     ;decrement operand
  223.     dec    (hl)            ; 35
  224.     dec    offset(ix)        ; DD 35 55
  225.     dec    offset(iy)        ; FD 35 55
  226.     dec    a            ; 3D
  227.     dec    b            ; 05
  228.     dec    bc            ; 0B
  229.     dec    c            ; 0D
  230.     dec    d            ; 15
  231.     dec    de            ; 1B
  232.     dec    e            ; 1D
  233.     dec    h            ; 25
  234.     dec    hl            ; 2B
  235.     dec    ix            ; DD 2B
  236.     dec    iy            ; FD 2B
  237.     dec    l            ; 2D
  238.     dec    sp            ; 3B
  239.     ;***********************************************************
  240.     ;disable interrupts
  241.     di                ; F3
  242.     ;***********************************************************
  243.     ;decrement b and jump relative if b # 0
  244.     djnz    .+0x12            ; 10 10
  245.     ;***********************************************************
  246.     ;enable interrupts
  247.     ei                ; FB
  248.     ;***********************************************************
  249.     ;exchange location and (sp)
  250.     ex    (sp),hl            ; E3
  251.     ex    (sp),ix            ; DD E3
  252.     ex    (sp),iy            ; FD E3
  253.     ;***********************************************************
  254.     ;exchange af and af'
  255.     ex    af,af'            ; 08
  256.     ;***********************************************************
  257.     ;exchange de and hl
  258.     ex    de,hl            ; EB
  259.     ;***********************************************************
  260.     ;exchange:
  261.     ;    bc <-> bc'
  262.     ;    de <-> de'
  263.     ;    hl <-> hl'
  264.     exx                ; D9
  265.     ;***********************************************************
  266.     ;halt (wait for interrupt or reset)
  267.     halt                ; 76
  268.     ;***********************************************************
  269.     ;set interrupt mode
  270.     im    0            ; ED 46
  271.     im    1            ; ED 56
  272.     im    2            ; ED 5E
  273.     ;***********************************************************
  274.     ;load 'a' with input from device n
  275.     in    a,(n)            ; DB 20
  276.     ;***********************************************************
  277.     ;load register with input from (c)
  278.     in    a,(c)            ; ED 78
  279.     in    b,(c)            ; ED 40
  280.     in    c,(c)            ; ED 48
  281.     in    d,(c)            ; ED 50
  282.     in    e,(c)            ; ED 58
  283.     in    h,(c)            ; ED 60
  284.     in    l,(c)            ; ED 68
  285.     ;***********************************************************
  286.     ;increment operand
  287.     inc    (hl)            ; 34
  288.     inc    offset(ix)        ; DD 34 55
  289.     inc    offset(iy)        ; FD 34 55
  290.     inc    a            ; 3C
  291.     inc    b            ; 04
  292.     inc    bc            ; 03
  293.     inc    c            ; 0C
  294.     inc    d            ; 14
  295.     inc    de            ; 13
  296.     inc    e            ; 1C
  297.     inc    h            ; 24
  298.     inc    hl            ; 23
  299.     inc    ix            ; DD 23
  300.     inc    iy            ; FD 23
  301.     inc    l            ; 2C
  302.     inc    sp            ; 33
  303.     ;***********************************************************
  304.     ;load location (hl) with input
  305.     ;from port (c)
  306.     ;decrement 'hl' and 'b'
  307.     ind                ; ED AA
  308.     ;***********************************************************
  309.     ;load location (hl) with input
  310.     ;from port (c)
  311.     ;